<?php
declare(strict_types = 1);

namespace app\index\service;

use think\facade\Session;
use think\facade\Config;
use think\facade\Cache;
use think\admin\Service as AdminService;
use \app\index\service\ConfigService;

class MessageService extends AdminService
{

    //初始化配置
    protected $table = 'Message';//表名

    // 初始化
    protected function initialize()
    {
        //$this->config = config('excel');//调用配置文件示例
    }

    

    /**
    * 方法说明 构造信息体
    * @author    saruri <saruri@163.com>
    * @date      2021/03/02 10:11:59  
    * @auth false
    * @menu false
    * @login false
    * @throws \think\Exception
    * @throws \think\db\exception\DataNotFoundException
    * @throws \think\db\exception\DbException
    * @throws \think\db\exception\ModelNotFoundException
    */ 
    public function  build($frame)
    {
        //do somehing
        //exit("这里是:");
        $messageBody = '框架FRAMEID->'.$frame->fd."saruri hello Now Time:".date("h:i:s").'内容'.$frame->data;
        return $messageBody;
    }



    /**
    * 方法说明构造 数组 
    * @author    saruri <saruri@163.com>
    * @date      2021/03/04 11:04:36  
    * @auth true
    * @menu true
    * @login true
    * @throws \think\Exception
    * @throws \think\db\exception\DataNotFoundException
    * @throws \think\db\exception\DbException
    * @throws \think\db\exception\ModelNotFoundException
    */ 
    public function  getMessage($frame)
    {
        //do somehing
        $d=json_decode($frame->data,true);
        $data=$d[1]['message'];
        $arr['page']=$data['page']['detail'];
        //md5
        //configList
        $arr['messageBody']['md5']=$data['md5'];
        //$arr['messageBody']['filePath']=ConfigService::instance()->getFilePath($data['md5']);
        $arr['messageBody']['configList']=$data['configList'];
        $arr['tab']=$data['tab'];
        $arr['totalData']=$data['page']['totalData'];
        $arr['totalPage']=$data['page']['totalPage'];//总页数
        $arr['perPage']=$data['page']['perPage'];//每页百分比
        $arr['perNum']=$data['page']['perNum'];//每页百分比
        $arr['dataZone']=$data['page']['dataZone'];//每页百分比
        //$arr['test']=$data;
        return $arr; 
    }


  //  page":{"total":109,"totalData":108,"totalPage":6,"perNum":20,"perPage":19,"dataZone":{"start":2,"end":109},"detail":[{"start":1,"end":20},
  //  {"start":21,"end":40},{"start":41,"end":60},{"start":61,"end":80},{"start":81,"end":100},{"start":101,"end":109}]}},"event":"sendMqSuccess","fd":1



}
